package net.mikoo.seals.api.model.workflow;

import java.util.ArrayList;
import java.util.List;

import net.mikoo.seals.api.model.BaseResponse;
import net.mikoo.seals.model.Workflow;
import net.mikoo.seals.model.WorkflowSetting;

public class GetPartyListResponse extends BaseResponse {

	private static final long serialVersionUID = 8144947712333229554L;

	private List<String> specialPartyNameList;
	
	private List<String> partyNameList;

	public List<String> getSpecialPartyNameList() {
		return specialPartyNameList;
	}

	public void setSpecialPartyNameList(List<String> specialPartyNameList) {
		this.specialPartyNameList = specialPartyNameList;
	}

	public List<String> getPartyNameList() {
		return partyNameList;
	}

	public void setPartyNameList(List<String> partyNameList) {
		this.partyNameList = partyNameList;
	}
	
	public static GetPartyListResponse valueOf(Workflow specialWorkflow, Workflow workflow) {
		GetPartyListResponse result = new GetPartyListResponse();
		
		if(specialWorkflow != null && specialWorkflow.getSettings() != null) {
			result.specialPartyNameList = getPartyName(specialWorkflow);
		}
		
		if(workflow != null && workflow.getSettings() != null) {
			result.partyNameList = getPartyName(workflow);
		}
		return result;
	}

	private static List<String> getPartyName(Workflow workflow){
		List<String> result = new ArrayList<String>();
		if(workflow != null && workflow.getSettings() != null) {
			for(WorkflowSetting setting : workflow.getSettings()) {
				if(setting == null) {
					continue;
				}
				result.add(setting.getPerson().getName());
			}
		}
		return result;
	}
	
}
